package ca.usherbrooke.builder.entity;

import java.io.FileNotFoundException;
import java.io.IOException;

import ca.usherbrooke.view.properties.PropertieBase;

public class EntityModelObjectBuilder {
	private final static String NAME = "entity_model_name_key";

	// position key
	private final static String POSITION_X = "position_x_key";
	private final static String POSITION_Y = "position_Y_key";
	private final static String POSITION_WIDTH = "position_width_key";
	private final static String POSITION_HEIGHT = "position_height_key";

	// jump key
	private final static String JUMP_RELOAD_TIMEMS = "jumpReloadTimeMs_key";
	private final static String MAX_JUMP_DURATION_IN_MS = "maxJumpDurationInMs_key";

	// speed key
	private final static String MAX_SPEED_VALUE = "max_speed_value_key";
	private final static String CURRENT_SPEED_X = "current_speed_x_key";
	private final static String CURRENT_SPEED_Y = "current_speed_y_key";

	// fight key
	private final static String MAX_HP = "max_hp_key";
	private final static String CURRENT_HP = "current_hp_key";
	private final static String ATTACK_RELOAD_TIME_MS = "attack_reload_time_ms_key";
	private final static String REMAINING_ATTACK_RELOAD_TIME_MS = "remaining_attack_reload_time_Ms_key";
	private final static String CURRENT_ATTACK_MODIFIER = "current_attack_modifier_key";
	private final static String DAMAGE_ADD = "damage_add_key";

	// vision key
	private final static String VISION_WIDTH = "vision_width_key";
	private final static String VISION_HEIGHT = "vision_height_key";

	// equipments key
	private final static String EQUIPMENTS_CAPACITY = "capacity_key";

	public static EntityModelObject createEntityObject(String fileName)
			throws FileNotFoundException, IOException {

		PropertieBase properties = new PropertieBase(fileName);

		EntityModelObject entityObject = new EntityModelObject();

		// entity name
		entityObject.name = properties.getValue(EntityModelObjectBuilder.NAME);

		// entity position
		entityObject.positionX = properties
				.getFloatValue(EntityModelObjectBuilder.POSITION_X);
		entityObject.positionY = properties
				.getFloatValue(EntityModelObjectBuilder.POSITION_Y);
		entityObject.positionWidth = properties
				.getFloatValue(EntityModelObjectBuilder.POSITION_WIDTH);
		entityObject.positionHeight = properties
				.getFloatValue(EntityModelObjectBuilder.POSITION_HEIGHT);

		// entity jump
		entityObject.jumpReloadTimeMs = properties
				.getIntegerValue(EntityModelObjectBuilder.JUMP_RELOAD_TIMEMS);
		entityObject.maxJumpDurationInMs = properties
				.getIntegerValue(EntityModelObjectBuilder.MAX_JUMP_DURATION_IN_MS);

		// entity speed
		entityObject.maxSpeedValue = properties
				.getFloatValue(EntityModelObjectBuilder.MAX_SPEED_VALUE);
		entityObject.currentSpeedX = properties
				.getFloatValue(EntityModelObjectBuilder.CURRENT_SPEED_X);
		entityObject.currentSpeedY = properties
				.getFloatValue(EntityModelObjectBuilder.CURRENT_SPEED_Y);

		// entity fight
		entityObject.maxHp = properties
				.getIntegerValue(EntityModelObjectBuilder.MAX_HP);
		entityObject.currentHp = properties
				.getIntegerValue(EntityModelObjectBuilder.CURRENT_HP);

		entityObject.attackReloadTimeMs = properties
				.getIntegerValue(EntityModelObjectBuilder.ATTACK_RELOAD_TIME_MS);
		entityObject.remainingAttackReloadTime = properties
				.getIntegerValue(EntityModelObjectBuilder.REMAINING_ATTACK_RELOAD_TIME_MS);
		entityObject.currentAttackModifier = properties
				.getIntegerValue(EntityModelObjectBuilder.CURRENT_ATTACK_MODIFIER);
		entityObject.damageAdd = properties
				.getIntegerValue(EntityModelObjectBuilder.DAMAGE_ADD);

		// entity vision
		entityObject.visionWidth = properties
				.getFloatValue(EntityModelObjectBuilder.VISION_WIDTH);
		entityObject.visionHeight = properties
				.getFloatValue(EntityModelObjectBuilder.VISION_HEIGHT);

		// entity equipments
		entityObject.maxCapacity = properties
				.getIntegerValue(EntityModelObjectBuilder.EQUIPMENTS_CAPACITY);

		return entityObject;
	}
}
